package com.dxf.sysadmin.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

import java.io.Serializable;
import java.util.Objects;

/**
 * 角色-菜单表
 */
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@TableName("`role-menu`")
@ApiModel(value="Role-menu对象", description="角色-菜单表")
public class RoleMenu extends Model<RoleMenu> {

    private static final long serialVersionUID = 1L;

    /**
     *菜单Id
     */
    @ApiModelProperty(value = "菜单Id")
    @TableField("menuId")
    private Long menuId;

    /**
     *角色Id
     */
    @ApiModelProperty(value = "角色Id")
    //@TableField("roleId")
    @TableId(value = "roleId", type = IdType.INPUT)
    private Long roleId;


    @Override
    protected Serializable pkVal() {
        return null;
    }

    /**
     *list.contains()方法判断是否包含,需要在user中复写equals()方法
     */
    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (!(o instanceof RoleMenu)) {
            return false;
        }
        RoleMenu roleMenu = (RoleMenu) o;
        return menuId.equals(roleMenu.menuId) &&
                roleId.equals(roleMenu.roleId);
    }

    @Override
    public int hashCode() {
        return Objects.hash(menuId, roleId);
    }
}
